<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input type="text" placeholder="请输入id" v-model="id"> <input type="text" placeholder="请输入姓名" v-model="name"> <button @click="add">添加用户</button>

        <ul>
            <li v-for="(item, index) in peoples" :key="item.id">
                <input type="checkbox"> {{item.name}}
            </li>
        </ul>

    </div>
    <script src="./js/vue.js"></script>
    <script>
        new Vue({
            data: {
                peoples: [
                    // {
                    //     id: 1,
                    //     name: '张三'
                    // },
                    // {
                    //     id: 2,
                    //     name: '李四'
                    // },
                    // {
                    //     id: 3,
                    //     name: '王五'
                    // }
                ],


                // person: {
                //     id: '',
                //     name: ''
                // },

                id: '',
                    name: ''
            },


            methods: {
                add() {
                    // var obj = Object.assign({}, this.person)
                    // console.log(obj)
                    let obj = {
                        id: this.id,
                        name: this.name
                    }
                    this.peoples.unshift(obj)
                }
            }
        }).$mount('#app')
    </script>
</body>
</html>